def strStr(haystack, needle):
    len_need = len(needle)
    if len_need == 0: return 0
    len_hay = len(haystack)
    if len_hay == 0: return -1
    i, j = 0, 0
    start = i
    while i < len_hay and j < len_need:
        if haystack[i] == needle[j]:
            i += 1
            j += 1
        else:
            j = 0
            start += 1
            i = start
    return i - len_need if j >= len_need else -1


# print(strStr('hello', 'll'))  # 2
# print(strStr('aaaaaa', 'bba'))  # -1
# print(strStr('', ''))  # 0
print(strStr("mississippi", "issi"))  # 1
